﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Data;
namespace CIT.WMS.houseWork.Bll
{
    public class Bllb_Storage_tbs
    {
        static bool flag = true;
        static bool result = true;

        public static DataTable QueryLocation(string StrWhere)
        {
            string sqlcmd = string.Format(@"SELECT *  FROM dbo.T_Bllb_Storage_tbs AS a
LEFT JOIN dbo.T_Bllb_StorageArea_tbsa AS b ON a.Storage_SN=b.Storage_SN
LEFT JOIN dbo.T_Bllb_StorageLocation_tbsl AS c ON b.Area_SN=c.Area_SN {0}", StrWhere);
            return Utils.NMS.QueryDataTable(Utils.uContext, sqlcmd, new CIT.WMS.MESWcf.CmdParameter[0]);
        }
        public static bool UpdateStockInfo(string SN, string stockSN, int qty, string s_Doc)
        {
            string sqlcmd = string.Format(@"UPDATE dbo.T_Bllb_StockInfo_tbsi SET Storage_SN='{1}',Area_SN='', Location_SN='',QTY='{2}',Lock_Flag='0',TBS_ID='' WHERE SerialNumber='{0}'
UPDATE T_Bllb_StorageDocDetail_tbsdd SET Receive_Flag='Y' WHERE SerialNumber='{0}' and S_Doc_NO='{3}'", SN, stockSN, qty, s_Doc);
            Utils.NMS.Exectransql(Utils.uContext, sqlcmd, new CIT.WMS.MESWcf.CmdParameter[0], out flag, out result);
            return flag;
        }
        public static bool UpdateStock(string SN, string stockSN, string areaSN, string locationSN, int qty, string s_Doc)
        {
            string sqlcmd = string.Format(@"UPDATE T_Bllb_StockInfo_tbsi SET Storage_SN='{1}',Area_SN='{2}',Location_SN='{3}',QTY='{4}',Lock_Flag='0',TBS_ID='' WHERE SerialNumber='{0}'
UPDATE T_Bllb_StorageDocDetail_tbsdd SET Receive_Flag='Y' WHERE SerialNumber='{0}' and S_Doc_NO='{5}'", SN, stockSN, areaSN, locationSN, qty, s_Doc);
            Utils.NMS.Exectransql(Utils.uContext, sqlcmd, new CIT.WMS.MESWcf.CmdParameter[0], out flag, out result);
            return flag;
        }

    }
}
